package TransactionImplementation

import (
	"salary-payment/AbstractTransaction"
	"salary-payment/DataBase"
	"salary-payment/Model"
	"salary-payment/ModelImplementation"
	"reflect"
)

type ChangeUnAffiliationTransaction struct {
	AbstractTransaction.ChangeAffiliationTransaction
}

func (c *ChangeUnAffiliationTransaction) RecordMembership(employee *Model.Employee) {
	af := employee.GetAffiliation()

	if reflect.TypeOf(af) == reflect.TypeOf(ModelImplementation.UnionAffiliation{}) {
		uaf := af.(*ModelImplementation.UnionAffiliation)
		memberId := uaf.GetMemberId()
		DataBase.PayrollDatabase.RemoveUnionMember(memberId)
	}
}

func (c *ChangeUnAffiliationTransaction) GetAffiliation() Model.Affiliation {
	return Model.NoAffiliation{}
}
